package com.yhgarden.bbs.config;

import com.yhgarden.bbs.model.interceptor.AuthenticationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

    @Autowired
    private AuthenticationInterceptor authenticationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**")
                //公共接口
                .excludePathPatterns(new String[]{"/error/**","/common/**","/common/websocket/**"})
                //第三方接口
                .excludePathPatterns(new String[]{"/thirdPartApi/aliyunAreas/**"})
                //后台接口
                .excludePathPatterns(new String[]{"/system/systemUser/login","/system/systemUser/judgeLogin","/system/systemUser/logout"})
                //PC端业务接口
                .excludePathPatterns(new String[]{"/pc/dataStatistics/**","/pc/shufflingFigure/**","/pc/section/queryForList","/pc/systemMessage/**",
                        "/pc/mainPost/queryForList","/pc/businessSelectItem/**","/pc/baseSelectItem/**","/pc/hotSearch/**"})
                //PC端用户接口
                .excludePathPatterns(new String[]{"/pc/user/login","/pc/user/judgeLogin","/pc/user/logout","/pc/user/register","/pc/user/forgetPassword/verifyAccount",
                        "/pc/user/forgetPassword/resetPassword"});
        super.addInterceptors(registry);
    }
}
